import React, { Component } from 'react';
import $axios from 'axios';
import Mock from 'mockjs';

const post = (url, data = {}) => {
    return new Promise((resolve, reject) => {
        $axios({
            method: 'post',
            data: data,
            url: url,
        }).then((res) => {
            resolve(res)
        }).
        catch((err) => {
            console.log('err消息------', err)
        })
    })
}

const get = (url, data = {}) => {
    return new Promise((resolve, reject) => {
        $axios({
            method: 'get',
            data: data,
            url: url,
        }).then((res) => {
            resolve(res)
        }).
        catch((err) => {
            console.log('err消息------', reject(err))
        })
    })
}
const mock =(data)=>{
    return new Promise((resolve,reject)=>{  
        resolve(Mock.mock(data))

    })
}

export default {
    get,
    post,
    mock
};